package com.temple.common.enums;

import com.temple.common.exception.TempleException;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

///1境内汇款 2跨境汇款
@Getter
public enum TransferTypeEnums {


    CROSS_BORDER(2, "跨境汇款"),

    TERRITORY(1, "境内汇款");


    private Integer code;

    private String msg;


    TransferTypeEnums(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static TransferTypeEnums getEnum(Integer code) {
        Optional<TransferTypeEnums> optional = Arrays.asList(values()).stream()
                .filter(t -> Objects.equals(code, t.getCode())).findFirst();
        if (optional.isPresent()) {
            return optional.get();
        } else {
            throw new TempleException("未知枚举类型");
        }


    }
}
